################################################################################
#
#               The Filibuster and Legislative Discussion
#
#                             Fu and Howell
#
#                                Nov 2022
#
################################################################################

library(tidyverse) 
library(lfe)
library(stargazer)


###################   Analysis 2: Landmark Legislation   #######################

### Raw Data ###

# landmark legislation
landmark2007 <- read_csv("~/Dropbox/FuHowell_Filibuster_Replication/data/landmark2007.csv")

# congressional major party agenda priorities
priority2007 <- read_csv("~/Dropbox/FuHowell_Filibuster_Replication/data/priority2007.csv")


### Analysis ###

# Table 2: 

# time spent on landmark legislation
mod_landmark2007_1 <- lm(days_senate ~ normChange + days_house + senate_bill, data = landmark2007[landmark2007$congress %in% c(109:110) & landmark2007$budgetRecon == 0,])
mod_landmark2007_2 <- lm(days_senate ~ normChange + days_house + senate_bill, data = landmark2007[landmark2007$congress %in% c(108:111) & landmark2007$budgetRecon == 0,])
mod_landmark2007_3 <- lm(days_senate ~ normChange + days_house + senate_bill, data = landmark2007[landmark2007$congress %in% c(107:112) & landmark2007$budgetRecon == 0,])
mod_landmark2007_4 <- lm(days_senate ~ normChange + days_house + senate_bill, data = landmark2007[landmark2007$congress %in% c(106:113) & landmark2007$budgetRecon == 0,])
mod_landmark2007_5 <- lm(days_senate ~ normChange + days_house + senate_bill, data = landmark2007[landmark2007$congress %in% c(105:114) & landmark2007$budgetRecon == 0,])

stargazer(mod_landmark2007_1, mod_landmark2007_2, mod_landmark2007_3, mod_landmark2007_4, mod_landmark2007_5,
          type = "text",
          dep.var.caption = c("Dependent Variable: Considering Days in Senate"),
          dep.var.labels = "Landmark Legislation",
          column.labels = c("1 session", "2 sessions", "3 sessions", "4 sessions", "5 sessions"), 
          covariate.labels = c("Filibuster Norm Change", "Considering Days in House", "Introduced in Senate"),
          omit.stat = c("adj.rsq", "f", "ser"))

# time spent on majority party agendas
mod_prioriry2007_1 <- lm(days_senate ~ normChange + days_house + senate_bill, data = priority2007[priority2007$congress %in% c(109:110) & priority2007$budget_recon == 0,])
mod_prioriry2007_2 <- lm(days_senate ~ normChange + days_house + senate_bill, data = priority2007[priority2007$congress %in% c(108:111) & priority2007$budget_recon == 0,])
mod_prioriry2007_3 <- lm(days_senate ~ normChange + days_house + senate_bill, data = priority2007[priority2007$congress %in% c(107:112) & priority2007$budget_recon == 0,])
mod_prioriry2007_4 <- lm(days_senate ~ normChange + days_house + senate_bill, data = priority2007[priority2007$congress %in% c(106:113) & priority2007$budget_recon == 0,])
mod_prioriry2007_5 <- lm(days_senate ~ normChange + days_house + senate_bill, data = priority2007[priority2007$congress %in% c(105:114) & priority2007$budget_recon == 0,])

stargazer(mod_prioriry2007_1, mod_prioriry2007_2, mod_prioriry2007_3, mod_prioriry2007_4, mod_prioriry2007_5,
          type = "text",
          dep.var.caption = c("Dependent Variable: Considering Days in Senate"),
          dep.var.labels = "Majority Party Agendas",
          column.labels = c("1 session", "2 sessions", "3 sessions", "4 sessions", "5 sessions"), 
          covariate.labels = c("Filibuster Norm Change", "Considering Days in House", "Introduced in Senate"),
          omit.stat = c("adj.rsq", "f", "ser"))




### APPENDIX ###


# Table A.9: Successfully Enacted Elements of Majority Party Agendas

mod_success2007_1c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(109:110) & priority2007$budget_recon == 0 & priority2007$outcome != 3,])
mod_success2007_2c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(108:111) & priority2007$budget_recon == 0 & priority2007$outcome != 3,])
mod_success2007_3c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(107:112) & priority2007$budget_recon == 0 & priority2007$outcome != 3,])
mod_success2007_4c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(106:113) & priority2007$budget_recon == 0 & priority2007$outcome != 3,])
mod_success2007_5c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(105:114) & priority2007$budget_recon == 0 & priority2007$outcome != 3,])

stargazer(mod_success2007_1c, mod_success2007_2c, mod_success2007_3c, mod_success2007_4c, mod_success2007_5c,
          type = "text",
          dep.var.caption = c("Dependent Variable: Considering Days in Senate"),
          column.labels = c("1 session", "2 sessions", "3 sessions", "4 sessions", "5 sessions"), 
          covariate.labels = c("Filibuster Norm Change", "Considering Days in House", "Introduced in Senate",
                               "Divided Government", "Divided Chambers", "Senate Polarization"),
          omit.stat = c("adj.rsq", "f", "ser"))

# Table A.10: Failed Enacted Elements of Majority Party Agendas

mod_fail2007_1c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(109:110) & priority2007$budget_recon == 0 & priority2007$outcome == 3,])
mod_fail2007_2c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(108:111) & priority2007$budget_recon == 0 & priority2007$outcome == 3,])
mod_fail2007_3c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(107:112) & priority2007$budget_recon == 0 & priority2007$outcome == 3,])
mod_fail2007_4c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(106:113) & priority2007$budget_recon == 0 & priority2007$outcome == 3,])
mod_fail2007_5c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(105:114) & priority2007$budget_recon == 0 & priority2007$outcome == 3,])

stargazer(mod_fail2007_1c, mod_fail2007_2c, mod_fail2007_3c, mod_fail2007_4c, mod_fail2007_5c,
          type = "text",
          dep.var.caption = c("Dependent Variable: Considering Days in Senate"),
          column.labels = c("1 session", "2 sessions", "3 sessions", "4 sessions", "5 sessions"), 
          covariate.labels = c("Filibuster Norm Change", "Considering Days in House", "Introduced in Senate",
                               "Divided Government", "Divided Chambers", "Senate Polarization"),
          omit.stat = c("adj.rsq", "f", "ser"))


# Table A.11: Congressional Session Related Covariates Included


mod_landmark2007_1c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = landmark2007[landmark2007$congress %in% c(109:110) & landmark2007$budgetRecon == 0,])
mod_landmark2007_2c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = landmark2007[landmark2007$congress %in% c(108:111) & landmark2007$budgetRecon == 0,])
mod_landmark2007_3c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = landmark2007[landmark2007$congress %in% c(107:112) & landmark2007$budgetRecon == 0,])
mod_landmark2007_4c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = landmark2007[landmark2007$congress %in% c(106:113) & landmark2007$budgetRecon == 0,])
mod_landmark2007_5c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = landmark2007[landmark2007$congress %in% c(105:114) & landmark2007$budgetRecon == 0,])

stargazer(mod_landmark2007_1c, mod_landmark2007_2c, mod_landmark2007_3c, mod_landmark2007_4c, mod_landmark2007_5c,
          type = "text",
          dep.var.caption = c("Dependent Variable: Considering Days in Senate"),
          dep.var.labels = "Landmark Legislation",
          column.labels = c("1 session", "2 sessions", "3 sessions", "4 sessions", "5 sessions"), 
          covariate.labels = c("Filibuster Norm Change", "Considering Days in House", "Introduced in Senate",
                               "Divided Government", "Divided Chambers", "Senate Polarization"),
          omit.stat = c("adj.rsq", "f", "ser"))


mod_prioriry2007_1c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(109:110) & priority2007$budget_recon == 0,])
mod_prioriry2007_2c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(108:111) & priority2007$budget_recon == 0,])
mod_prioriry2007_3c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(107:112) & priority2007$budget_recon == 0,])
mod_prioriry2007_4c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(106:113) & priority2007$budget_recon == 0,])
mod_prioriry2007_5c <- lm(days_senate ~ normChange + days_house + senate_bill + divided_gov + divided_chambers + senate_polar, data = priority2007[priority2007$congress %in% c(105:114) & priority2007$budget_recon == 0,])

stargazer(mod_prioriry2007_1c, mod_prioriry2007_2c, mod_prioriry2007_3c, mod_prioriry2007_4c, mod_prioriry2007_5c,
          type = "text",
          dep.var.caption = c("Dependent Variable: Considering Days in Senate"),
          dep.var.labels = "Majority Party Agendas",
          column.labels = c("1 session", "2 sessions", "3 sessions", "4 sessions", "5 sessions"), 
          covariate.labels = c("Filibuster Norm Change", "Considering Days in House", "Introduced in Senate",
                               "Divided Government", "Divided Chambers", "Senate Polarization"),
          omit.stat = c("adj.rsq", "f", "ser"))






